﻿namespace Sedodream.Web.Common.View
{
    using System.Collections.Generic;
    using System.Web.Mvc;
    using Sedodream.Web.Common.View.HtmlView;

    public static class HtmlHelperExtensions
    {
        #region Textbox
        public static IViewObject NewText(
            this HtmlHelper htmlHelper, string name)
        {
            return NewText(htmlHelper, name, null);
        }

        public static IViewObject NewText(
            this HtmlHelper htmlHelper, string name, string labelText)
        {
            return NewText(htmlHelper, name, labelText, null);
        }

        public static IViewObject NewText(
            this HtmlHelper htmlHelper, string name, string labelText, object value)
        {
            return NewText(htmlHelper, name, labelText, value, null, false, true, null);
        }

        public static IViewObject NewText(
            this HtmlHelper htmlHelper, string name, string labelText, object value,
            string validationMessage, bool @readonly, bool createLi, object attributes)
        {
            IViewObject viewObject = new HtmlText(
                new ViewRequestContext(htmlHelper), name, labelText, value,
                validationMessage, @readonly, createLi, attributes);
            viewObject.StartView();
            return viewObject;
        }
        #endregion

        #region List items
        public static IViewObject NewRadioButtonGroup(
            this HtmlHelper htmlHelper, string name)
        {
            return NewRadioButtonGroup(htmlHelper, name, null);
        }

        public static IViewObject NewRadioButtonGroup(
            this HtmlHelper htmlHelper, string name,
            IEnumerable<SelectListItem> selectList)
        {
            return NewRadioButtonGroup(htmlHelper, name, selectList, true, null);
        }

        public static IViewObject NewRadioButtonGroup(
            this HtmlHelper htmlHelper, string name,
            IEnumerable<SelectListItem> selectList,
            bool createLi, object attributes)
        {
            IViewObject viewObject = new HtmlRadioButtonGroup(
                new ViewRequestContext(htmlHelper), name, selectList, createLi, attributes);
            viewObject.StartView();
            return viewObject;
        }
        #endregion

        #region HtmlFieldset
public static IViewObject NewHtmlFieldset(
    this HtmlHelper htmlhelper, string name, string title, object attributes)
{
    IViewObject viewObject = new HtmlFieldset(
        new ViewRequestContext(htmlhelper), name, title, attributes);
    viewObject.StartView();
    return viewObject;
}
        #endregion
    }
}

